import { createStore, createLogger } from 'vuex';
import getters from './getters';
import createPersistedState from 'vuex-persistedstate';
import { store as user, State as UserState } from '@/store/modules/user';
import { store as layout, State as layoutState } from '@/store/modules/layout';

// 在开发环境中开启logger
const debug = import.meta.env.DEV;

const plugins = debug ? [createLogger()] : [];
// 可以根据自己需要添加其他插件，例如：vuex持久化插件
plugins.push(createPersistedState());

export type RootState = {
    layout: layoutState;
    user: UserState;
};

const store = createStore({
    modules: {
        layout,
        user,
    },
    getters,
    plugins,
});

export default store;
